<?php
session_start();


include_once($_SERVER['DOCUMENT_ROOT'] ."/include/user/inc.php");
include_once($_SERVER['DOCUMENT_ROOT'] ."/include/mblog/inc.php");
include_once( $_SERVER['DOCUMENT_ROOT']  . '/mblog/inc.php' );

$token = $_SESSION['token']['access_token'];
#$token = "2.005hzbtBooBFMCcd363e9be20JZ5vX";

$c = new SaeTClientV2( WB_AKEY , WB_SKEY , $token );
$current_uid = $c->get_uid();
$current_uid = $current_uid["uid"];
	
if(!$current_uid)
{
	header("Location:/mblog/token/");
}
$mod_get_mblog_by_token = new mod_get_mblog_by_token();
$black_list = $mod_get_mblog_by_token->api_get_blocking_by_token($token,1,20);

$db_fanlaji_jubao_uid = new db_fanlaji_jubao_uid();
$jubao_list = $db_fanlaji_jubao_uid->get_list_by_uid(1,500,$current_uid);

$laji_uid_array = array();
foreach($jubao_list as $value)
{
	$laji_uid_array[] = $value["laji_uid"];
}

$at_me_list = $c->mentions( $page = 1, $count = 200, $since_id = 0, $max_id = 0, $filter_by_author = 0, $filter_by_source = 0, $filter_by_type = 0);//根据ID获取用户等基本信息

$laji_info = array();

foreach($at_me_list["statuses"] as $key => $value)
{

	if(in_array($value["user"]["id"],$laji_uid_array))
	{
		continue;
	}
	if($value["user"] && $value["user"]["verified_type"] < 1 &&  !$value["user"]["following"] && (!$value["user"]["bi_followers_count"] || $value["user"]["followers_count"] < 20 ||($value["user"]["followers_count"] / $value["user"]["bi_followers_count"] > 10 ))  )
	{
		preg_match_all("/@(.*?)[\s|#|@]/",$value["text"],$match);
		if(count($match[1]) > 5)
		{
			$laji_text = $value["text"];
			if($value["retweeted_status"]["text"])
			{
				$laji_text .= "-----------------转发内容分割线--------------{$value["retweeted_status"]["text"]}";
			}
			$laji_info[] = array("laji_uid"=>$value["user"]["id"] ,"laji_nickname"=>$value["user"]["screen_name"],"laji_text"=>$laji_text,
			"laji_pic"=>$value["user"]["profile_image_url"] );
		}
	}
	
}
$db_fanlaji_laji_uid = new db_fanlaji_laji_uid();
$laji_top = $db_fanlaji_laji_uid->get_laji_uid_list_order_by_jubao($current_uid,1,8);//未被删除的用户取20个

$g_show["black_list"] = $black_list["data"]["result"];
$g_show["jubao_list"] = $jubao_list;
$g_show["laji_info"] = $laji_info;

$g_show["laji_top"] = $laji_top;



//当前用户信息

$user_info = new user_info();
$is_login = $user_info->is_logined();

if($is_login)
{
	$user_detail_info = $user_info->get_cur_user_info();
	$uid = $user_detail_info["uid"];
	$user_nickname = $user_detail_info["user_nickname"];
	$g_show["current_user_info"] = $user_detail_info;
	$g_show["is_logined"] = true;
}









$smarty = p_get_smarty();	
$smarty->assign("g_show", $g_show);

$smarty->display("mblog/fanlaji/at_res.html");

if (isset($_GET["debug"]))
{
	print_r($_COOKIE);
	print_r($g_show);
}

